package com.corejava.training.collections.car.pre15.immutable;
import java.util.*;

public class CellphoneImmutableDemo {

	/**
	 * @param args
	 */
	public static void main(String[] args) {

		// create 3 instances of CellphoneImmutable 
		CellphoneImmutable cim1 = new CellphoneImmutable("samsung", "smartphone", "galaxy S4", "Android 4.2.0", 699.89);
		CellphoneImmutable cim2 = new CellphoneImmutable("Nokia", "smartphone", "Lukimia", "Android 4.2.0", 199.89);
		CellphoneImmutable cim3 = new CellphoneImmutable("Apple", "smartphone", "Iphone 5", "AIOS", 799.89);
		
		// create a list and add objects to it
		List cellphoneList = new ArrayList();
		cellphoneList.add(cim1);
		cellphoneList.add(cim2);
		cellphoneList.add(cim3);
		
		// read thru the objects and print out with jdk 1.4 style
		Iterator ite = cellphoneList.iterator();
		while(ite.hasNext()){
			CellphoneImmutable cellphoneImmutable = (CellphoneImmutable)ite.next();
			System.out.println("Company = " + cellphoneImmutable.getCompany()); 
			System.out.println("Model = " + cellphoneImmutable.getModel());
			System.out.println("Description = " + cellphoneImmutable.getDescription());
			System.out.println("operatingSystem = " + cellphoneImmutable.getOperatingSystem());
			System.out.println("Price = " + cellphoneImmutable.getPrice());
			System.out.println("-------------------------");
			
			// create list with Generics signature and add instances of class to it
			List<CellphoneImmutable> alist = new ArrayList<CellphoneImmutable>();
			alist.add(cim1);
			alist.add(cim2);
			alist.add(cim3);
			
			// read from the list and print out
			for (CellphoneImmutable cellphoneImmutable2 : alist) {
				System.out.println("START ENHANCED FOR LOOP");
				System.out.println("Company = " + cellphoneImmutable.getCompany()); 
				System.out.println("Model = " + cellphoneImmutable.getModel());
				System.out.println("Description = " + cellphoneImmutable.getDescription());
				System.out.println("operatingSystem = " + cellphoneImmutable.getOperatingSystem());
				System.out.println("Price = " + cellphoneImmutable.getPrice());
				System.out.println("-------------------------");
				
			}
			
		}
		
		
	}

}
